//服务  : 就是一个异步函数, 返回promise，组件可以调用服务

//异步函数需要处理的是: 前端到后端的请求,返回promise交由给组件

import request from '../plugins/umi-request';

export const queryHome = async params => request.get(`/api/home`,{params: params || {_limit:30,_page:1}});

export const queryFollow = async params => request.get(`/api/follow`,{params: params || {_limit:20,_page:1}});

export const queryColumn = async params => request.get(`/api/column`,{params: params || {_limit:15,_page:1}});

export const queryBanner = async params => request.get(`/api/banner`,{params: params || {_limit:3,_page:1}});

export const queryDetail = async ({_id,collectionName}) => request.get(
  `/api/${collectionName}/${_id}`);

export const queryAll = async () => Promise.all([
  queryHome(),
  queryBanner()
]);
